VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Begin VB.Form frmAdminConsole 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Adminstrative Console"
   ClientHeight    =   5580
   ClientLeft      =   45
   ClientTop       =   615
   ClientWidth     =   8670
   HelpContextID   =   200
   Icon            =   "Admin Console Master.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   Picture         =   "Admin Console Master.frx":27A2
   ScaleHeight     =   5580
   ScaleWidth      =   8670
   StartUpPosition =   2  'CenterScreen
   Begin MSComDlg.CommonDialog dlgAdmin 
      Left            =   300
      Top             =   480
      _ExtentX        =   847
      _ExtentY        =   847
      _Version        =   393216
   End
   Begin MSComctlLib.StatusBar barBottomStatusBar 
      Align           =   2  'Align Bottom
      Height          =   360
      Left            =   0
      TabIndex        =   0
      Top             =   5220
      Width           =   8670
      _ExtentX        =   15293
      _ExtentY        =   635
      _Version        =   393216
      BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628} 
         NumPanels       =   6
         BeginProperty Panel1 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
            AutoSize        =   1
            Object.Width           =   10239
         EndProperty
         BeginProperty Panel2 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
            Style           =   6
            Alignment       =   1
            AutoSize        =   2
            Object.Width           =   1376
            MinWidth        =   9
            TextSave        =   "14/07/03"
         EndProperty
         BeginProperty Panel3 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
            Style           =   5
            Alignment       =   1
            AutoSize        =   2
            Object.Width           =   873
            MinWidth        =   9
            TextSave        =   "20:43"
         EndProperty
         BeginProperty Panel4 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
            Style           =   2
            Alignment       =   1
            AutoSize        =   2
            Object.Width           =   820
            MinWidth        =   9
            TextSave        =   "NUM"
         EndProperty
         BeginProperty Panel5 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
            Style           =   1
            Alignment       =   1
            AutoSize        =   2
            Enabled         =   0   'False
            Object.Width           =   900
            MinWidth        =   9
            TextSave        =   "CAPS"
         EndProperty
         BeginProperty Panel6 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
            Style           =   4
            Alignment       =   1
            AutoSize        =   2
            Enabled         =   0   'False
            Object.Width           =   900
            MinWidth        =   2
            TextSave        =   "SCRL"
         EndProperty
      EndProperty
   End
   Begin VB.Image Image1 
      Height          =   5760
      Left            =   -60
      Picture         =   "Admin Console Master.frx":6024
      Stretch         =   -1  'True
      Top             =   -60
      Width           =   8760
   End
   Begin VB.Menu mnuAdmin 
      Caption         =   "&Admin"
      Begin VB.Menu mnuAdmin_ManageUserAccounts 
         Caption         =   "&Manage User Accounts"
      End
      Begin VB.Menu mnuAdmin_ChangeAdminPassword 
         Caption         =   "&Change Admin Password"
      End
      Begin VB.Menu mnuAdmin_Bar1 
         Caption         =   "-"
      End
      Begin VB.Menu mnAdmin_RepairOptimiseDatabase 
         Caption         =   "&Repair/Optimise Database"
      End
      Begin VB.Menu mnuAdmin_ResetDatabasePath 
         Caption         =   "Reset Database &Path"
      End
      Begin VB.Menu mnuAdmin_InstallSampleDatabase 
         Caption         =   "Install Sample Database"
      End
      Begin VB.Menu mnuAdmin_InstallBlankDatabase 
         Caption         =   "&Install Blank Database"
      End
      Begin VB.Menu mnuAdmin_Bar2 
         Caption         =   "-"
      End
      Begin VB.Menu mnuAdmin_Help 
         Caption         =   "&Help"
         Shortcut        =   {F1}
      End
      Begin VB.Menu mnuAdmin_About 
         Caption         =   "&About...."
      End
      Begin VB.Menu mnuAdmin_Bar3 
         Caption         =   "-"
      End
      Begin VB.Menu mnuAdmin_exit 
         Caption         =   "E&xit"
      End
   End
End
Attribute VB_Name = "frmAdminConsole"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'************************************************************************************
'*                  Adminstrative Console Main Form                                 *
'*      The startup form for the adminstrative console. Provides menu               *
'*      for accessing adminstrative tools. Its start up is unique in that           *
'*      it does not reference the generic start up form and does not actually       *
'*      open any databases during startup. Also locks the user name textbox in the  *
'*      log in form and sets user name to Admin. Requires that users be logged      *
'*      in under this account                                                       *
'************************************************************************************


Option Explicit

'Loading flag, used to ensure that Form Activate is executed only during loading
Private Loading As Boolean

Private Sub Form_Activate()
    On Local Error GoTo errorHandler
    
    If Loading Then
        Loading = False
        'Initialise Help System
        Set HelpDialogue = dlgAdmin
        App.HelpFile = getHelpFilePath
        
        'Set the user name to admin and lock user name text box
        frmSystem_LogIn.txtUserName.Text = "Admin"
        frmSystem_LogIn.txtUserName.Locked = True
        
        'Center log in form on console form
        frmSystem_LogIn.Left = Me.Left + (Me.Width / 2) - (frmSystem_LogIn.Width / 2)
        frmSystem_LogIn.Top = Me.Top + (Me.Height / 2) - (frmSystem_LogIn.Height / 2)
        frmSystem_LogIn.Show vbModal, Me
            
        'Not really necesary but just in case.......
        If Not TextTheSame(CurrentUser.UserName, "admin") Then
            MsgBox "You must log in as Admin to use the the adminstrative console", vbCritical
            End
        End If
        
        barBottomStatusBar.Panels(1).Text = "Logged in as " & CurrentUser.UserName
        
        
    End If
        
    
Exit Sub
errorHandler:
    'All errors are considered fatal
    MsgBox Err.Description, vbCritical
    End
    
End Sub

Private Sub Form_Load()

    Loading = True
End Sub

Private Sub mnAdmin_RepairOptimiseDatabase_Click()
    On Local Error GoTo errorHandler
    
    Dim strTempDB As String
    Dim strCurrentDB As String
    Dim objFileSystem As New FileSystemObject
    
    'Get a temporary file name
    Do
        strTempDB = objFileSystem.GetTempName
    Loop Until Not objFileSystem.FileExists(strTempDB)
    
    'get path of current db
    strCurrentDB = GetDatabasePath
    
    'Compact Database to temp file
    DBEngine.CompactDatabase strCurrentDB, strTempDB, , , ";pwd=25081982"
    
    'Delete current file
    objFileSystem.DeleteFile strCurrentDB
    
    'reassign old db the current file name
    objFileSystem.MoveFile strTempDB, strCurrentDB
    
    'report success
    MsgBox "Database successfully compacted.", vbInformation

Exit Sub

errorHandler:
    'all errors result in an abortion
    MsgBox Err.Description, vbCritical
    
End Sub

Private Sub mnuAdmin_exit_Click()
    Unload Me
End Sub

Private Sub mnuAdmin_Help_Click()
    ShowHelpTopic 200
End Sub

Private Sub mnuAdmin_InstallBlankDatabase_Click()
    frmAdminConsole_DBInitialisation.Show vbModal, Me
End Sub

Private Sub mnuAdmin_ChangeAdminPassword_Click()
    frmSystem_ChangePassword.Show vbModal, Me
End Sub

Private Sub mnuAdmin_InstallSampleDatabase_Click()
    frmAdminConsole_InstallSampleDB.Show vbModal, Me
End Sub

Private Sub mnuAdmin_ResetDatabasePath_Click()
    On Local Error GoTo errorHandler
    
    'Get filename
    With dlgAdmin
        .DialogTitle = "New Database Path"
        .Filter = "Databases (*.mdb)|*.mdb|All Files|(*.*)"
        .Flags = cdlOFNPathMustExist + cdlOFNFileMustExist
        .FileName = ""
        .CancelError = True
        .ShowSave
    End With
    
    'update registry entry
    SaveSetting regAppName, regSection, regKeyDBPath, dlgAdmin.FileName
    MsgBox "New Database Path Set", vbInformation

Exit Sub

errorHandler:
    If Err.Number <> cdlCancel Then
        MsgBox Err.Description, vbExclamation, "Path Not Changed"
    End If
    
End Sub

Private Sub mnuAdmin_ManageUserAccounts_Click()
    On Local Error Resume Next
    frmAdminConsole_UserAccounts.Show vbModal, Me
    
End Sub

Private Sub mnuAdmin_About_Click()
    frmSystem_AboutBox.Show vbModal, Me
End Sub
